void main() {
  // 准备购物车数据
  List carts = [
    {"count": 2, "price": 10.0, "selected": true},
    {"count": 1, "price": 30.0, "selected": false},
    {"count": 5, "price": 20.0, "selected": true}
  ];
  // print('是否全选：${getSelectedState2(carts)}');
  isSelectedAll(getSelectedState1(carts));
}

isSelectedAll(bool value) {
  print(value ? '全选' : '非全选');
}

bool getSelectedState1(List params) {
  final result = params.every((item) => item['selected']);
  return result;
}

bool getSelectedState2(List params) {
  bool result = true;
  params.forEach((item) {
    if (!item['selected']) result = false;
    return;
  });
  return result;
}

bool getSelectedState3(List params) {
  bool result = true;
  for (var item in params) {
    if (!item['selected']) result = false;
    break;
  }
  return result;
}
